cmake_minimum_required (VERSION 3.10)
set (CMAKE_SKIP_BUILD_RPATH TRUE)
set (EXE_NAME "httpdd")
set (POST "post")
set (RAW "raw")
set (JSON "json")
set (TRANS_DIFF "trans_diff")

project (${EXE_NAME})

set (EXE_SOURCES
        src/main.cpp)

set (JSON_SOURCES
        src/json.cpp)

set (POST_SOURCES
        src/post.cpp)

set (TRANS_DIFF_SOURCES
        src/trans_diff.cpp)

set (RAW_SOURCES
        src/raw.cpp)

include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(src)
add_compile_options(-O0 -g -W -Wall -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-delete-abstract-non-virtual-dtor)

set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

add_library(${JSON} SHARED ${JSON_SOURCES})
set_target_properties(${JSON} PROPERTIES VERSION 1.0.0)
set_target_properties(${JSON} PROPERTIES LIBRARY_OUTPUT_DIRECTORY lib64)
add_executable(${EXE_NAME} ${EXE_SOURCES})
set (CMAKE_LINK_LIBRARY_FLAG "-L${PROJECT_BINARY_DIR}/lib64 ${CMAKE_LINK_LIBRARY_FLAG}")
target_link_libraries(${EXE_NAME} pthread)
target_link_libraries(${EXE_NAME} json)
add_dependencies(${EXE_NAME} ${JSON})

add_executable(${POST} ${POST_SOURCES})
target_link_libraries(${POST} pthread)
target_link_libraries(${POST} json)
add_dependencies(${POST} ${JSON})

add_executable(${TRANS_DIFF} ${TRANS_DIFF_SOURCES})
target_link_libraries(${TRANS_DIFF} pthread)
target_link_libraries(${TRANS_DIFF} json)
add_dependencies(${TRANS_DIFF} ${JSON})

add_executable(${RAW} ${RAW_SOURCES})
target_link_libraries(${RAW} pthread)
target_link_libraries(${RAW} json)
add_dependencies(${RAW} ${JSON})

configure_file(src/json.h ${PROJECT_BINARY_DIR}/include/json.h)
configure_file(src/http.h ${PROJECT_BINARY_DIR}/include/http.h)